<template>
	<view class="wrap u-padding-30">
		<view class="top"></view>

		<view class="payment-info">
			<view class="u-p-t-30 u-p-b-30 bold">收银台动态授权码</view>

			<view class="calculation-data">
				<!-- <view class="data-title">订单流水号</view> -->
				<view class="data-text">
					说明：每个授权码有效时间：3分钟；每个授权码只重使用一次；使用后请重新获得新的授权码。
				</view>
			</view>
			
			
		</view>
		
		<view class="u-text-center u-padding-50"><text class="u-font-xl" style="color: red;font-weight: bold;">{{auth_code}}</text></view>

		<view class="u-text-center u-padding-50">
			<template>
				<u-button type="primary" size="medium" @click="getAuthCode">
					<text style="margin-right: .5em;">
					</text><text>重新获取</text>
				</u-button>
			</template>		
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				auth_code: '',
				user: {},
				shop: {},
				payment: {}
			}
		},
		onLoad(options) {
			this.getUserInfo()
			this.queryPayment()
		},
		onShow() {
			this.getAuthCode()
		},
		methods: {
			getAuthCode() {
				this.$u.post('/admin/cashier/auth-code', {}).then(res => {
					console.log(res)
					this.auth_code = res.auth_code;
				}).catch(e => {
					console.log(e)
				})
			},
			getUserInfo() {
				this.$u.post('/user/info', {}).then(res => {
					this.user = res;
				}).catch(e => {
					console.log(e)
				})
			},
			setDelivery(){
				this.$u.post('/admin/delivery/set-delivery', {payment_id:this.payment.id}).then(res => {
					uni.showToast({
						title: '发货完成',
						icon: 'success'
					});
					this.queryPayment();
				}).catch(e => {
					console.log(e)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		font-size: 28rpx;

		.content {
			width: 600rpx;
			margin: 80rpx auto 0;

			.title {
				text-align: left;
				font-size: 60rpx;
				font-weight: 500;
				margin-bottom: 100rpx;
			}

			input {
				text-align: left;
				margin-bottom: 10rpx;
				padding-bottom: 6rpx;
			}

			.tips {
				color: $u-type-info;
				margin-bottom: 60rpx;
				margin-top: 8rpx;
			}

			.getCaptcha {
				background-color: rgb(253, 243, 208);
				color: $u-tips-color;
				border: none;
				font-size: 30rpx;
				padding: 12rpx 0;

				&::after {
					border: none;
				}
			}

			.alternative {
				color: $u-tips-color;
				display: flex;
				justify-content: space-between;
				margin-top: 30rpx;
			}
		}

		.buttom {
			.loginType {
				display: flex;
				padding: 350rpx 150rpx 150rpx 150rpx;
				justify-content: space-between;

				.item {
					display: flex;
					flex-direction: column;
					align-items: center;
					color: $u-content-color;
					font-size: 28rpx;
				}
			}

			.hint {
				padding: 20rpx 40rpx;
				font-size: 20rpx;
				color: $u-tips-color;

				.link {
					color: $u-type-warning;
				}
			}
		}

		.payment-info {
			background-color: #FFF;
			padding: 0 30rpx 30rpx 30rpx;
			border-radius: 10rpx;
			box-sizing: border-box;
			margin-bottom: 30rpx;

			.bold {
				font-weight: bold;
				border-bottom: 1rpx solid #c9c8d2;
			}

			.calculation-data {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				padding-top: 30rpx;
				// margin-bottom: 10rpx;

				.data-title {
					width: 6em;
					font-weight: bold;
				}

				.data-text {
					flex: 1
				}
			}

		}
	}
</style>
